﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using ZFS.Library.Helper;
using ZFS.Model;
using ZFSData;

namespace ZFS.ServerLibrary
{
    public partial class BaseService : IBaseService
    {
        public byte[] GetDictionarys()
        {
            var dicList = Factory.GetDictionaryManager().GetDictionarys();
            byte[] bytes = ZipTools.CompressionObject(dicList);
            return bytes;
        }

        public byte[] GetModelsByDic(byte[] search)
        {
            var DicSearch = ZipTools.DecompressionObject(search) as tb_Dictionary;
            var DicList = Factory.GetDictionaryManager().GetModels(DicSearch);
            byte[] bytes = ZipTools.CompressionObject(DicList);
            return bytes;
        }

        public byte[] GetPagingModelsByDic(int pageIndex, int pageSize, out int totalCount,
            byte[] search,
            bool Asc = false)
        {
            var DicSearch = ZipTools.DecompressionObject(search) as tb_Dictionary;
            var DicList = Factory.GetDictionaryManager().GetPagingModels(pageIndex, pageSize, out totalCount, DicSearch, Asc);
            byte[] bytes = ZipTools.CompressionObject(DicList);
            return bytes;
        }

        public bool DeleteEntityByDic(byte[] entity)
        {
            var dic = ZipTools.DecompressionObject(entity) as tb_Dictionary;
            return Factory.GetDictionaryManager().DeleteEntity(dic);
        }

        public bool UpdateEntityByDic(byte[] entity)
        {
            var dic = ZipTools.DecompressionObject(entity) as tb_Dictionary;
            return Factory.GetDictionaryManager().UpdateEntity(dic);
        }

        public byte[] AddEntityByDic(byte[] entity)
        {
            var dic = ZipTools.DecompressionObject(entity) as tb_Dictionary;
            var NewDic = Factory.GetDictionaryManager().UpdateEntity(dic);
            byte[] bytes = ZipTools.CompressionObject(NewDic);
            return bytes;
        }

        public bool ExistEntityByDic(byte[] entity)
        {
            var dic = ZipTools.DecompressionObject(entity) as tb_Dictionary;
            return Factory.GetDictionaryManager().ExistEntity(dic);
        }
    }
}
